package com.example.jdx_no_2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private Button btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8;
    private TextView text;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        text=findViewById(R.id.text);
        btn1=findViewById(R.id.btn1);
        btn1.setOnClickListener(MainActivity.this);
        btn2=findViewById(R.id.btn2);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                text.setText("使用匿名内部类");
            }
        });
        btn3=findViewById(R.id.btn3);
        btn4=findViewById(R.id.btn4);
        btn4.setOnClickListener(new Onclick());
        btn5=findViewById(R.id.btn5);
        btn5.setOnClickListener(new Myclick(text));
        btn6=findViewById(R.id.btn6);
        btn6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                text.setText("未使用该方法");
            }
        });
        btn7=findViewById(R.id.btn7);
        btn7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, 获取手机信息.class);
                startActivity(intent);
            }
        });
        btn8=findViewById(R.id.btn8);
        btn8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, 测试进度条.class);
                startActivity(intent);
            }
        });
    }
    public void a(View v){
        switch(v.getId()){
            case R.id.btn3:
                text.setText("使用标签");
                break;
        }
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn1:
                text.setText("使用Activity");
        }
    }
    class Onclick implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.btn4:
                    text.setText("使用内部类");
                    break;
            }
        }
    }
}
